<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function test() {
            console.log(arguments)
            // arguments.push(7)
        }
        test(1, 2, 2, 2)


        // 类数组：属性要为索引（数字）属性，必须有length属性，最好加上push方法
        var obj = {
            "0": 'a',
            "1": 'b',
            "2": 'c',
            length: 3,
            push: Array.prototype.push,
            spilce: Array.prototype.spilce
        }

        Array.prototype.push = function (target) {
            this[this.length] = target;
            this.length++
        }

        // 阿里题目
        var obj1 = {
            '2': 'a',
            '3': 'b',
            length: 2,
            push: Array.prototype.push
        }

        obj1.push("c")
        obj1.push('d')
        console.log(obj1)



        // 封装
        function type(target) {
            var template = {
                '[object Array]': 'array',
                '[object Object]': 'object',
                '[object Number]': 'number-object',
                '[object Boolean]': 'boolean-object',
                '[object String]': 'string-object',
            }
            if (target === null) {
                return null;
            }
            if (typeof (target) === 'object') {
                // 有数组、对象、包装类
                var str = Object.prototype.toString.call(target);
                return template[str];
            } else {
                return typeof (target)
            }
            // 1.分两类： 原始值、引用值
            // 2、区分引用值
        }

        // 数组去重
        Array.prototype.unique = function () {
            var temp = {};;
            var arr = [];
            var len = this.length;
            for (var i = 0; i < len; i++) {
                if (!temp[this[i]]) {
                    temp[this[i]] = 'abc'
                    this.arr.push(this[i])
                }
            }
            return arr;
        }
    </script>
</body>

</html>